package com.hzw.saas.api.property.enmus;

import cn.hutool.core.lang.Assert;

import java.util.Objects;

/**
 * 系统字典模块
 *
 * @author zzl
 * @since 09/13/2021
 */
public enum SysDictModuleEnum {

    BLANK("", ""),
    CUSTOMER("CUSTOMER", "客户模块"),
    CUSTOMER_LEVEL("CUSTOMER_LEVEL", "会员级别模块"),
    CHANNEL("CHANNEL", "渠道模块"),
    CHANNEL_SERVICE("CHANNEL_SERVICE", "渠道业务模块"),
    HPC("HPC", "超算模块"),
    STAFF("STAFF", "工作人员模块"),
    RELATION("RELATION", "客户与员工关系"),
    PRODUCT_SUB_TYPE("PRODUCT_SUB_TYPE", "体验云对应的产品类型"),
    PRODUCT_PARALLEL_MODEL("PRODUCT_PARALLEL_MODEL", "产品授权控制类型"),
    PRODUCT_MODULE_LICENSE("PRODUCT_MODULE_LICENSE", "产品子模块License"),
    EXPIRE_TIME("EXPIRE_TIME", "过期时间模块"),
    STORAGE("STORAGE", "存储模块"),
    PROJECT_APPLY("PROJECT_APPLY", "项目模块"),
    HPC_CONTRACT_TEMPLATE("HPC_CONTRACT", "HPC合同模版"),
    HPC_QINGYUN("HPC_QINGYUN", "HPC青云模块"),
    WEB_SHELL("WEB_SHELL", "web-shell模块"),
    TICKET("TICKET", "工单模块"),
    DEVICE_STUDIO("DEVICE_STUDIO", "Device Studio模块"),
    ;
    private final String module;
    private final String text;

    SysDictModuleEnum(String module, String text) {
        this.module = module;
        this.text = text;
    }

    public String getModule() {
        return module;
    }

    public String getText() {
        return text;
    }

    public static void assertValid(String module) {
        SysDictModuleEnum instance = instance(module);
        Assert.notNull(instance, "系统字典模块未知：{}", module);
    }

    public static SysDictModuleEnum instance(String module) {
        for (SysDictModuleEnum instance : SysDictModuleEnum.values()) {
            if (Objects.equals(instance.getModule(), module)) {
                return instance;
            }
        }
        return null;
    }
}
